<%@ page import="com.actimind.actitime.Keys,
                 com.actimind.actitime.util.TimeUtils,
                 com.actimind.actitime.util.NameUtil,
                 com.actimind.actitime.beans.UserBean"%>
<%@ taglib uri="/WEB-INF/at.tld" prefix="at" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%!
    private String printValue(int value)
    {
        if (value == 0) return "-";

        return TimeUtils.formatWork(value);
    }
%>
<html>
<head>
    <title><bean:write name="title-prefix" scope="application"/> Overtime Report</title>
    <link rel="stylesheet" href="../css/at.css" type="text/css">
    <script language="JavaScript" src="../js/at.js"></script>
    <style type="text/css">
    .nonworking
    {
        font-weight: normal;
    }
    </style>
</head>
<body bgcolor="#ffffff" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<bean:define id="report" name="<%=Keys.OVERTIME_REPORT_BEAN_KEY%>" type="com.actimind.actitime.resources.DailySummaryOvertimeReport"/>
<bean:define id="form" name="OvertimeReportForm" type="com.actimind.actitime.reports.OvertimeReportForm"/>

<jsp:include page="../top.jsp" flush="false">
    <jsp:param name="pageSection" value="reports"/>
    <jsp:param name="pageAction" value="overtime"/>
</jsp:include>

<table width="770" align="center" cellspacing="0" cellpadding="4" border="0">
<tr>
    <td class="pagetitle" valign="top">Overtime Report</td>
</tr>
<tr><td><at:errors/></td></tr>
<tr>
    <td><html:link page="/reports/overtime.do">
        &lt;&lt; Change report parameters
        </html:link>
    </td>
</tr>
<tr>
    <td class="text">
        <br>
        <span class="formblocktitle">Report parameters:</span>
        <%=report.getReportTitle(form.getDateRange(), !form.isAllUsers())%>
    </td>
</tr>
</table>

<table bgcolor="#CCCCCC" width="770" align="center" cellspacing="0" cellpadding="0" border="0">
<tr>
    <td bgcolor="#CCCCCC">
    <table width="100%" cellspacing="1" cellpadding="4" border="0">
    <tr>
        <td class="listtblcolheader"><img src="../img/pixel.gif" width=1 height=10/><br>Dates / Users<br><img src="../img/pixel.gif" width=1 height=10/></td>
        <td class="listtblcolheader" width="5%" align="center">Overtime</td>
    <logic:iterate id="username" name="report" property="usernames">
        <td class="reportcolheader" width="5%" align="center"><%=username%></td>
    </logic:iterate>
    </tr>
    <tr>
        <td class="reportrow0" align="right">Total:</td>
        <td class="reportrow0num" width="5%" align="center"><%=printValue(report.getTotalOvertime())%></td>
    <logic:iterate id="username" name="report" property="usernames">
        <td class="reportrow0num" width="5%" align="center"><%=printValue(report.getUserOvertime((String) username))%></td>
    </logic:iterate>
    </tr>
    <logic:iterate name="report" property="records" id="record" type="com.actimind.actitime.resources.DailySummaryOvertimeReport.Record" >
    <tr>
        <td class="reportrow2"><%=TimeUtils.toDateString(record.getDate())%> <%if(record.isHoliday()){%><span class="nonworking">(nonworking day)</span><%}%></td>
        <td class="reportrow2num" width="5%" align="center"><%=printValue(record.getTotalOvertime())%></td>
    <logic:iterate id="username" name="report" property="usernames">
        <td class="reportrow2num" width="5%" align="center"><%=printValue(record.getUserOvertime((String) username))%></td>
    </logic:iterate>
    </tr>
    </logic:iterate>
    </table>
    </td>
</tr>
</table>

</body>
</html>